package com.ruoyi.project.digital.utils;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;

import java.util.Date;

/**
 * @ClassName OrderUtil
 * @Description
 * @Author Small
 * @Date 2020/8/29 17:18
 * @Version 1.0
 **/
public class OrderUtil {

    /**
     * 创建订单号
     * 格式：年月日时分秒 + 会员id后四位 + 四位随机数
     * @param memberId
     * @return
     */
    public static String genOrderNum(Long memberId){
        String memStr = String.valueOf(memberId);
        if (memStr.length() < 4){
            memStr = String.format("%05d", memberId);
        }else{
            memStr = memStr.substring(memStr.length() - 4);
        }
        return DateUtil.format(new Date(), DatePattern.PURE_DATETIME_PATTERN) + memStr + RandomUtil.randomString("123456789",4);
    }

    public static void main(String[] args) {
        System.out.println(genOrderNum(1000001L));
        System.out.println( RandomUtil.randomNumbers(6));


        //InputStream inputStream = Order.class.getClassLoader().getResourceAsStream("/cert/apiclient_cert.p12");

        System.out.println(111);
    }
}
